import Amysql
import collections

#读出数据库数据
data=Amysql.Afetchall('localhost','root','123456','apple','select * from all_data ;')

new_data=collections.Counter(data['first_c_tag'])

#创建数据库表txt_data
sql='create table txt_data(word varchar(100) ,value varchar (10));'
Amysql.Acreatetalbes('localhost','root','123456','apple',sql)


for word,key in new_data.items():
    if '计算机' in str(word) :
        pass
    elif '网' in str(word):
        pass
    else:
        #插入数据到xtx表
        sql = "insert into txt_data(word,value) values('%s','%s');" % (word,key)
        Amysql.Ainsert('localhost', 'root', '123456', 'apple', sql)


